<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page import="sg.edu.nus.iss.phoenix.schedule.entity.Utility" %>
<%@ page import="sg.edu.nus.iss.phoenix.utils.CommonUtils" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 
<html>
<head>
<link href="<c:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
<fmt:setBundle basename="ApplicationResources" />
<title> <fmt:message key="title.crudrp"/> </title>
</head>
<body>
  
        <h1><fmt:message key="label.schedulep.edit"/></h1>
        <a href="/phoenixradio/pages/crudSchedule.jsp"><fmt:message key="label.schedulep.add"/></a>
        |
        <a href="/phoenixradio/pages/modifySchedule.jsp"  onclick="window.open('reviewScheduledProgram.jsp', '_blank', 'height=300, width=300');"><fmt:message key="label.schedulep.edit" /></a>
        |
        <a href="/phoenixradio/pages/copySchedule.jsp"  onclick="window.open('reviewScheduledProgram.jsp', '_blank', 'height=300, width=300');"><fmt:message key="label.schedulep.copy" /></a>
        |
        <a href="/phoenixradio/pages/deleteSchedule.jsp" onclick="window.open('reviewScheduledProgram.jsp', '_blank', 'height=300, width=300');"><fmt:message key="label.schedulep.delete" /></a>
        <br/><br/>
		<form action="${pageContext.request.contextPath}/controller/createSchedule" method=post>
		 Week
		<select name="week_number" >
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
			<option value="5">5</option>
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
		</select>
		<select name="annual_year">
			<option value="2012">2012</option>
			<option value="2013">2013</option>
			<option value="2014">2014</option>
			<option value="2015">2015</option>
		</select>
		<br><br>
			<table id="dataTable" class="borderAll">
			<tr>
				
				<th> Day</th>
                <th> Start HH </th>
				<th> Start MM </th>
				<th> End HH </th>
				<th> End MM </th>
				<th> Radio Program </th>
				<th> Presenter </th>
				<th> Producer </th>
			</tr>
         	<c:forEach var="programSlot" items="${weeklySchedule.programSlotsforWeek}" varStatus="status">
				<tr class="${status.index%2==0?'even':'odd'}">
				
					<td class="nowrap">
						<fmt:parseDate var="dateObj" value="${programSlot.dateofWeek}" type="DATE" pattern="yyyy-MM-dd"/>
						<c:set var="now" value="${dateObj}" />
						<fmt:formatDate  pattern="E"  value="${now}" var="selectedDay" />
						<select id="start_week_day" onchange="getSelectedValueStartDate();" name="startDate">
							<option value="1"  ${selectedDay=='Mon' ? 'selected' : ''} >Monday</option>
							<option value="2"  ${selectedDay=='Tue' ? 'selected' : ''}>Tuesday</option>
							<option value="3"  ${selectedDay=='Wed' ? 'selected' : ''}>Wednesday</option>
							<option value="4"  ${selectedDay=='Thu' ? 'selected' : ''}>Thursday</option>
							<option value="5"  ${selectedDay=='Fri' ? 'selected' : ''}>Friday</option>
							<option value="6"  ${selectedDay=='Sat' ? 'selected' : ''}>Saturday</option>
							<option value="7"  ${selectedDay=='Sun' ? 'selected' : ''}>Sunday</option>
						</select>
					</td>
					<td class="nowrap">
					<c:set var="start_hour" value="${programSlot.startTime}"/>
					<c:set var="hh" value="${fn:substring(start_hour, 1, 2)}" />
					<c:set var="mm" value="${fn:substring(start_hour, 3, 4)}" />
						<select id="start_time_hh"  name="startHour">
							<option value="1" ${hh=='1' ? 'selected' : ''}>01</option>
							<option value="2" ${hh=='2' ? 'selected' : ''} >02</option>
							<option value="3" ${hh=='3' ? 'selected' : ''}>03</option>
							<option value="4" ${hh=='4' ? 'selected' : ''}>04</option>
							<option value="5" ${hh=='5' ? 'selected' : ''}>05</option>
							<option value="6" ${hh=='6' ? 'selected' : ''} >06</option>
							<option value="7" ${hh=='7' ? 'selected' : ''}>07</option>
							<option value="8" ${hh=='8' ? 'selected' : ''}>08</option>
							<option value="9" ${hh=='9' ? 'selected' : ''}>09</option>
							<option value="10" ${hh=='10' ? 'selected' : ''}>10</option>
							<option value="11" ${hh=='11' ? 'selected' : ''}>11</option>
							<option value="12" ${hh=='12' ? 'selected' : ''}>12</option>
							<option value="13" ${hh=='13' ? 'selected' : ''}>13</option>
							<option value="14" ${hh=='14' ? 'selected' : ''}>14</option>
							<option value="15" ${hh=='15' ? 'selected' : ''}>15</option>
							<option value="16" ${hh=='16' ? 'selected' : ''}>16</option>
							<option value="17" ${hh=='17' ? 'selected' : ''}>17</option>
							<option value="18" ${hh=='18' ? 'selected' : ''}>18</option>
							<option value="19" ${hh=='19' ? 'selected' : ''}>19</option>
							<option value="20" ${hh=='20' ? 'selected' : ''}>20</option>
							<option value="21" ${hh=='21' ? 'selected' : ''}>21</option>
							<option value="22" ${hh== '22' ? 'selected' : ''}>22</option>
							<option value="23" ${hh=='23' ? 'selected' : ''}>23</option>
							<option value="0" ${hh=='00' ? 'selected' : ''}>00</option>
							</select>
						
					</td>
					<td class="nowrap">
						<select id="start_time_mm"  onchange="getSelectedValueStartMin()" name="startTimeMin">
						<option value="00"  ${mm=='00' ? 'selected' : ''}>00</option>
						<option value="30"  ${mm=='30' ? 'selected' : ''}>30</option>
						</select>
						
					</td>
					<td class="nowrap">
					<c:set var="end_hour" value="${programSlot.endTime}"/>
					<c:set var="hh" value="${fn:substring(end_hour, 1, 2)}" />
					<c:set var="mm" value="${fn:substring(end_hour, 3, 4)}" />
						<select id="end_time_hh"  name="endHour">
							<option value="1" ${hh=='1' ? 'selected' : ''}>01</option>
							<option value="2" ${hh=='2' ? 'selected' : ''} >02</option>
							<option value="3" ${hh=='3' ? 'selected' : ''}>03</option>
							<option value="4" ${hh=='4' ? 'selected' : ''}>04</option>
							<option value="5" ${hh=='5' ? 'selected' : ''}>05</option>
							<option value="6" ${hh=='6' ? 'selected' : ''} >06</option>
							<option value="7" ${hh=='7' ? 'selected' : ''}>07</option>
							<option value="8" ${hh=='8' ? 'selected' : ''}>08</option>
							<option value="9" ${hh=='9' ? 'selected' : ''}>09</option>
							<option value="10" ${hh=='10' ? 'selected' : ''}>10</option>
							<option value="11" ${hh=='11' ? 'selected' : ''}>11</option>
							<option value="12" ${hh=='12' ? 'selected' : ''}>12</option>
							<option value="13" ${hh=='13' ? 'selected' : ''}>13</option>
							<option value="14" ${hh=='14' ? 'selected' : ''}>14</option>
							<option value="15" ${hh=='15' ? 'selected' : ''}>15</option>
							<option value="16" ${hh=='16' ? 'selected' : ''}>16</option>
							<option value="17" ${hh=='17' ? 'selected' : ''}>17</option>
							<option value="18" ${hh=='18' ? 'selected' : ''}>18</option>
							<option value="19" ${hh=='19' ? 'selected' : ''}>19</option>
							<option value="20" ${hh=='20' ? 'selected' : ''}>20</option>
							<option value="21" ${hh=='21' ? 'selected' : ''}>21</option>
							<option value="22" ${hh== '22' ? 'selected' : ''}>22</option>
							<option value="23" ${hh=='23' ? 'selected' : ''}>23</option>
							<option value="0" ${hh=='00' ? 'selected' : ''}>00</option>
							</select>
						
					
					</td>
					<td class="nowrap">
					<select id="end_time_mm" onchange="getSelectedValueEndMin();" name="endTimeMin">
						<option value="00"  ${mm=='00' ? 'selected' : ''}>00</option>
						<option value="30"  ${mm=='30' ? 'selected' : ''}>30</option>
					</select>
					</td>
					<td class="nowrap"><input type="text" name="programs_list" value="${programSlot.radioProgramId}"></input></td>
					<td class="nowrap"><input type="text" name="presenter_list" value="${programSlot.presenterId}"></input></td>
					<td class="nowrap"><input type="text" name="producer_list" value="${programSlot.producerId}"></input></td>
				</tr>
			</c:forEach>
			</table>
			</form>
			<tr>
				<td colspan="2" align="center"><input type="submit" value="Modify" onClick="addSelection('3');"> </td>
			</tr>
</body>
</html>